package tcss543.test;

import tcss543.*;

public class MatchingAnalyzer {
	private DeviceGraph graph;
	
	public MatchingAnalyzer(DeviceGraph graph) {
		this.graph = graph;
	}
	
	public MatchingSummary analyze(int[][] matching) {
		int requestorCount = 0;
		int requestorUnits = 0;
		int helperCount = 0;
		for (int i = 0; i < matching.length; i++) {
			if (matching[i] != null) {
				requestorCount++;
				requestorUnits += graph.getR()[i];
				helperCount += matching[i].length;
			}
		}
		
		MatchingSummary summary = new MatchingSummary();
		summary.matchedRequestorCount = requestorCount;
		summary.matchedRequestedUnits = requestorUnits;
		summary.matchedHelperCount = helperCount;
		summary.avgHelpersPerRequestor = (double)helperCount / (double)requestorCount;
		return summary;
	}
}
